import 'package:flutter/material.dart';
import 'package:httpdio/screens/posts_screen.dart';
import 'package:httpdio/screens/user_screen.dart';
import 'package:provider/provider.dart';

import 'comments_screen.dart';

class MainNavigationScreen extends StatefulWidget {
  const MainNavigationScreen({super.key});

  @override
  _MainNavigationScreenState createState() => _MainNavigationScreenState();
}

class _MainNavigationScreenState extends State<MainNavigationScreen> {
  int _currentIndex = 0;
  final List<Widget> _screens = [
    const UserScreen(),
    const PostsScreen(),
    const CommentsScreen(),
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: _screens[_currentIndex],
      bottomNavigationBar: BottomNavigationBar(
        currentIndex: _currentIndex,
        onTap: (index) => setState(() => _currentIndex = index),
        items: const[
          BottomNavigationBarItem(icon: Icon(Icons.people),label: '用户'),
          BottomNavigationBarItem(icon: Icon(Icons.article),label: '帖子'),
          BottomNavigationBarItem(
            icon: Icon(Icons.comment),
            label: '评论',
          ),
        ],
      ),
    );
  }
}
